package finance

import (
	"github.com/gin-gonic/gin"
	"likeadmin/admin/schemas/req"
	"likeadmin/admin/service/finance"
	"likeadmin/constant"
	"likeadmin/core"
	"likeadmin/core/request"
	"likeadmin/core/response"
	"likeadmin/middleware"
	"likeadmin/util"
)

var AccountLogGroup = core.Group("/finance/account_log", newLogHandler, regLog, middleware.TokenAuth())

func newLogHandler(srv finance.IUserAccountLogService) *logHandler {
	return &logHandler{srv: srv}
}

func regLog(rg *gin.RouterGroup, group *core.GroupBase) error {
	return group.Reg(func(handle *logHandler) {
		rg.GET("/lists", handle.list)
		rg.GET("/getUmChangeType", handle.getUmChangeType)
	})
}

type logHandler struct {
	srv finance.IUserAccountLogService
}

// list log列表
func (h logHandler) list(c *gin.Context) {
	var page request.PageReq
	var listReq req.UserAccountLogListReq
	if response.IsFailWithResp(c, util.VerifyUtil.VerifyQuery(c, &page)) {
		return
	}
	if response.IsFailWithResp(c, util.VerifyUtil.VerifyQuery(c, &listReq)) {
		return
	}
	res, err := h.srv.List(c, page, listReq)
	response.CheckAndRespWithData(c, res, err)
}

// getUmChangeType 列表
func (h logHandler) getUmChangeType(c *gin.Context) {

	response.OkWithData(c, constant.ChangeTypeDesc)
}
